'use strict';
angular.module('clientApp')
.directive('viewpanneau', function() {
    return {
        restrict : 'E',
        scope : {
            selected : '='
        },
        link : function($scope) {
        	$scope.$watch('selected', function() {
        		if ($scope.selected) {
        			$scope.departureTimeText = new Date($scope.selected.flight.departureTime).toLocaleString();
                	$scope.arrivalTimeText = new Date($scope.selected.flight.arrivalTime).toLocaleString();
            		
                	angular.forEach($scope.selected.flight.hotels, function(value) {
            			if (value.classification === 'B') {
            				value.repeatClass = 2;
            			} else if (value.classification === 'C') {
            				value.repeatClass = 1;
            			} else {
            				value.repeatClass = 3;
            			}
            		});
        		}
        	});
        	
        	$scope.getNumber = function(num) {
        	    return new Array(num);   
        	};
        },
        templateUrl : 'views/directiveViewPanneau.html',
        replace : true
    };
});
